﻿using System;
using System.Collections.Generic;
using System.IO;
using System.Linq;
using System.Net;
using System.Text;
using System.Threading.Tasks;
using Ionic.Zip;

namespace LungSoundsPackager
{
    class Program
    {
        static void Main(string[] args)
        {
            Console.WriteLine(string.Format("Uploading {0} to: ftp://ph-mb.com/builds/{1:s}_Lung_Sounds_V2.zip", args[0], DateTime.Now));
            
            // Get the object used to communicate with the server.
            FtpWebRequest request = (FtpWebRequest)WebRequest.Create(string.Format("ftp://ph-mb.com/builds/{0:s}_Lung_Sounds_V2.zip", DateTime.Now));
            request.Method = WebRequestMethods.Ftp.UploadFile;


            //Console.WriteLine("Please enter FTP password: ");
            //String password = Console.ReadLine();

            // This example assumes the FTP site uses anonymous logon.
            request.Credentials = new NetworkCredential("lungsounds@ph-mb.com", "ilovefft");

            using (ZipFile zip = new ZipFile())
            {
                zip.AddDirectory(args[0]);

                zip.Comment = String.Format("Lung Sounds build on {0}", DateTime.Now);

                Stream requestStream = request.GetRequestStream();
                zip.Save(requestStream);

                requestStream.Close();
            }

            FtpWebResponse response = (FtpWebResponse)request.GetResponse();

            Console.WriteLine("Upload File Complete, status {0}", response.StatusDescription);

            Console.ReadLine();
            response.Close();
        }
    }
}
